<%--
  Created by IntelliJ IDEA.
  User: dzw
  Date: 2017/12/1
  Time: 11:00
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ page isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
  String path = request.getContextPath();
  String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";

%>

<div id="page-content">
  <div class="row">

    <div class="col-lg-12">
      <div class="panel">
        <div class="panel-heading">
          <h3 class="panel-title">沟通拜访</h3>
        </div>
        <div class="panel-body">
          <div class="form-inline">
            <div class="row">
              <div class="col-sm-12 table-toolbar-left">
                <btn id="btn_add_businessTalk" class="btn btn-primary btn-sm" ${isStart}>
                  <i class="ti-plus"> </i> 新建业务洽谈
                </btn>
              </div>
            </div>
          </div>
          <div class="table-jqgrid">
            <table id="businessTalk_table"></table>
            <div id="businessTalk_page"></div>
          </div>
        </div>
      </div>
    </div>

  </div>
</div>

<script>

  $(function(){

    init_grid_businessTalk();

  });

  function init_grid_businessTalk() {
    __init_jqgrid('businessTalk_table', 'businessTalk_page',
            '<%=path%>/com/businessTalk/list?viewtype=${viewtype}',
            ['客户名称',"洽谈主题",'洽谈方式',"洽谈地址","洽谈对象","操作","id"],
            [
              {name:'name',index:'name', width:100,search:true,sortable:true, searchoptions: {sopt: ['cn']}},
              {name:'talkTopic',index:'talkTopic', width:100,sortable:true,search:true, searchoptions: {sopt: ['cn']}},
              {name:'talkType',index:'talkType', width:120,search:true,sortable:true, searchoptions: {sopt: ['cn']}},
              {name:'talkAddress',index:'talkAddress',sortable:true,search:true,width:100, searchoptions: {sopt: ['cn']}},
              {name:'talkObject',index:'talkObject', search:true,sortable:true,width:150, searchoptions: {sopt: ['cn']}},
              {name:'act',index:'act', width:210,sortable:false,search:false,fixed:true,formatter: actFormat},
              {name:'id',index:'id',search:false,hidden:true}
            ],
            true,true
    );
  }

  function actFormat(cellvalue, options, rowObject){
    var id = rowObject.id;
    cellvalue = '<button class="btn btn-white btn-sm" onclick="fn_businessTalk_read(\'' + id + '\');"><i class="fa fa-eye"> </i> 查看</button>';

    return cellvalue;
  }

  function fn_businessTalk_read(id) {
    loadURL('<%=path%>/com/businessTalk/read?keyId='+id+'&viewtype=${viewtype}', $('#page-content'));
  }

  $("#btn_add_businessTalk").click(function(){
    loadURL('<%=path%>/com/businessTalk/input', $('#page-content'));
  });
</script>